unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdMailBox, frxDesgn, frxClass,
  RzButton, ExtCtrls, RzPanel, Grids, BaseGrid, AdvGrid;

type
  TForm1 = class(TForm)
    frxReport1: TfrxReport;
    frxUserDataSet1: TfrxUserDataSet;
    frxDesigner1: TfrxDesigner;
    RzToolbar1: TRzToolbar;
    RzToolButton1: TRzToolButton;
    RzToolButton2: TRzToolButton;
    RzToolButton3: TRzToolButton;
    AdvGrid1: TAdvStringGrid;
    RzToolButton4: TRzToolButton;
    RzToolButton5: TRzToolButton;
    RzToolButton6: TRzToolButton;
    procedure Button1Click(Sender: TObject);
    procedure frxReport1GetValue(const VarName: String;
      var Value: Variant);
    procedure frxReport1NewGetValue(Sender: TObject; const VarName: String;
      var Value: Variant);
    procedure frxUserDataSet1GetValue(const VarName: String;
      var Value: Variant);
    procedure FormShow(Sender: TObject);
    procedure RzToolButton1Click(Sender: TObject);
    procedure RzToolButton2Click(Sender: TObject);
    procedure RzToolButton3Click(Sender: TObject);
    procedure RzToolButton4Click(Sender: TObject);
    procedure RzToolButton5Click(Sender: TObject);
    procedure RzToolButton6Click(Sender: TObject);
  private
  public
    procedure SetGridParams;
  public
    procedure OnKzPrintMemoViewGetCellStylEvent(ACol,ARow:Integer;var Sender:TfrxCustomMemoView);
  end;

var
  Form1: TForm1;

implementation



{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  frxReport1.ShowReport();
end;

procedure TForm1.frxReport1GetValue(const VarName: String;
  var Value: Variant);
begin
  //
  if VarName='HelloWorld' then Value:='helloworld.demo';
end;

procedure TForm1.frxReport1NewGetValue(Sender: TObject;
  const VarName: String; var Value: Variant);
begin
  if VarName='HelloWorld' then Value:='helloworld.demo.new';
end;

procedure TForm1.frxUserDataSet1GetValue(const VarName: String;
  var Value: Variant);
begin
  if VarName='Field0' then Value:=AdvGrid1.Cells[0,frxUserDataSet1.RecNo];
  if VarName='Field1' then Value:=AdvGrid1.Cells[1,frxUserDataSet1.RecNo];
  if VarName='Field2' then Value:=AdvGrid1.Cells[2,frxUserDataSet1.RecNo];
  if VarName='Field3' then Value:=AdvGrid1.Cells[3,frxUserDataSet1.RecNo];
  if VarName='Field4' then Value:=AdvGrid1.Cells[4,frxUserDataSet1.RecNo];
  if VarName='Field5' then Value:=AdvGrid1.Cells[5,frxUserDataSet1.RecNo];
  if VarName='Field6' then Value:=AdvGrid1.Cells[6,frxUserDataSet1.RecNo];
  if VarName='Field7' then Value:=AdvGrid1.Cells[7,frxUserDataSet1.RecNo];
  if VarName='Field8' then Value:=AdvGrid1.Cells[8,frxUserDataSet1.RecNo];
  if VarName='Field9' then Value:=AdvGrid1.Cells[9,frxUserDataSet1.RecNo];
end;

procedure TForm1.SetGridParams;
var
  I,M:Integer;
begin
  with AdvGrid1 do
  begin
    BeginUpdate;

    DefaultColWidth:=80;
    ColCount:=10;
    RowCount:=10;

    for I:=0 to ColCount-1 do
    begin
      for M:=0 to RowCount-1 do
      begin
        Cells[I,M]:=Format('Cell:%D|%D',[I,M]);
      end;
    end;
    EndUpdate;
  end;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  SetGridParams;
end;

procedure TForm1.RzToolButton1Click(Sender: TObject);
var
  I:Integer;
  MemoA:TfrxMemoView;
begin
  frxUserDataSet1.RangeEnd:=reCount;
  frxUserDataSet1.RangeEndCount:=AdvGrid1.RowCount;

  for I:=0 to frxReport1.ComponentCount-1 do
  begin
    if frxReport1.Components[I] is TfrxMemoView then
    begin
      TfrxMemoView(frxReport1.Components[I]).OnGetCellStylEvent:=OnKzPrintMemoViewGetCellStylEvent;
    end;
  end;
  frxReport1.ShowReport();
end;

procedure TForm1.OnKzPrintMemoViewGetCellStylEvent(
  ACol,ARow:Integer; var Sender: TfrxCustomMemoView);
begin
  if (ACol=1) and (ARow=1) then
  begin
    Sender.HAlign:=frxClass.haRight;
    Sender.Font.Color:=clGreen;
  end;  
end;

procedure TForm1.RzToolButton2Click(Sender: TObject);
begin
  frxReport1.DesignReport();
end;

procedure TForm1.RzToolButton3Click(Sender: TObject);
begin
  Application.Terminate;
end;

procedure TForm1.RzToolButton4Click(Sender: TObject);
var
  I:Integer;

  BandA:TfrxBand;
begin
  //
  for I:=0 to frxReport1.Report.ComponentCount-1 do
  begin
    //
  end;  
  
end;

procedure TForm1.RzToolButton5Click(Sender: TObject);
var
  frxReport:TfrxReport;
  I:Integer;
begin
  {$IFDEF Delphi12}
  showmessage('delphi7');
  {$ELSE}
  {$ENDIF}
  frxReport:=TfrxReport.Create(nil);

  frxReport.LoadFromFile('00001.fr3');

  frxUserDataSet1.RangeEnd:=reCount;
  frxUserDataSet1.RangeEndCount:=AdvGrid1.RowCount;

  for I:=0 to frxReport.ComponentCount-1 do
  begin
    if frxReport.Components[I] is TfrxMemoView then
    begin
      TfrxMemoView(frxReport.Components[I]).OnGetCellStylEvent:=OnKzPrintMemoViewGetCellStylEvent;
    end;
  end;

  frxReport.OnGetValue:=frxReport1GetValue;
  
  frxReport.ShowReport();
end;

procedure TForm1.RzToolButton6Click(Sender: TObject);

var
a:Int64;begina:=20;ShowMessage(Format('%,3f',[a/2]));end;


end.
